#include<iostream>
using namespace std;
#define N 4

void display(int *a){
	int flag=0;
	for(int i=0;i<N*N;i++){
		cout<<*(a+i)<<" ";
		flag++;
		if(!(flag%4))
			cout<<endl;
		}
}
void S(int ar[N][N]){
	int b[N][N];
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			b[i][j]=ar[j][N-1-i];
		}
	}
	display(*b);
}
void IS(int ar[N][N]){
	int b[N][N];
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			b[i][j]=ar[N-1-j][i];
		}
	}
	display(*b);
}
int main(){
	int a[N][N]={{1,2,3,4},{9,10,11,12},{13,9,5,1},{15,11,7,3}};
	display(*a);
	cout<<endl;
	S(a);
	cout<<endl;
	IS(a);
	return 0;
}
